package com.itheima.reggie.controller;

import com.itheima.reggie.comon.ResultInfo;
import com.itheima.reggie.domain.Category;
import com.itheima.reggie.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/category")
public class CategoryController {
    @Autowired
    private CategoryService categoryService;

    //app端查询
    @GetMapping("/list")
    @Cacheable(value = "category",key = "'list'")
    public ResultInfo<List<Category>> findList() {
        List<Category> categoryList = categoryService.list();
        return ResultInfo.success(categoryList);
    }

}
